/*
 * $Id: PrimeSelector.java,v 1.5 2006/08/04 20:53:59 fran Exp $
 * 
 * Copyright (c) 2006 Fran Lattanzio
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package org.teneighty.fft;

import org.teneighty.fft.algorithms.DirectFourierTransform;
import org.teneighty.fft.algorithms.RaderFastFourierTransform;



/**
 * Select an appropiate transform, given a prime size.
 * <p>
 * This class was automatically generated by <code>PrimeSizeFinder</code>
 * on Thu Jun 15 12:00:25 EDT 2006. You should not edit this class.
 *
 * @author Fran Lattanzio
 * @version $Revision: 1.5 $ $Date: 2006/08/04 20:53:59 $
 */
public final class PrimeSelector
	extends Object
{


	/**
	 * Get a transform for the specified size.
	 * 
	 * @param size the size.
	 * @return FourierTransform the best known FourierTransform for the given size.
	 * @throws IllegalArgumentException If <code>size</code> is not prime.
	 */
	public static FourierTransform getFourierTransform( final int size ) 
		throws IllegalArgumentException
	{
		if( FourierTransformUtilities.isPrime( size ) == false )
		{
			throw new IllegalArgumentException();
		}

		switch( size )
		{
			case( 3 ):
			return( new DirectFourierTransform( 3 ) );
			case( 5 ):
			return( new DirectFourierTransform( 5 ) );
			case( 7 ):
			return( new DirectFourierTransform( 7 ) );
			case( 11 ):
			return( new DirectFourierTransform( 11 ) );
			case( 13 ):
			return( new DirectFourierTransform( 13 ) );
			case( 17 ):
			return( new DirectFourierTransform( 17 ) );
			case( 19 ):
			return( new DirectFourierTransform( 19 ) );
			case( 23 ):
			return( new DirectFourierTransform( 23 ) );
			case( 29 ):
			return( new DirectFourierTransform( 29 ) );
			case( 31 ):
			return( new DirectFourierTransform( 31 ) );
			case( 43 ):
			return( new DirectFourierTransform( 43 ) );
			case( 47 ):
			return( new DirectFourierTransform( 47 ) );
			case( 59 ):
			return( new DirectFourierTransform( 59 ) );
			case( 83 ):
			return( new DirectFourierTransform( 83 ) );
			case( 107 ):
			return( new DirectFourierTransform( 107 ) );
			case( 167 ):
			return( new DirectFourierTransform( 167 ) );
			case( 347 ):
			return( new DirectFourierTransform( 347 ) );
			default:
			return( new RaderFastFourierTransform( size ) );
		}
	}


	/**
	 * No instances.
	 *
	 * @throws InternalError always.
	 */
	private PrimeSelector()
		throws InternalError
	{
		throw new InternalError();
	}
}

